#!/usr/bin/env bash

status() {
  systemctl status NetworkManager
}

start() {
  systemctl start NetworkManager
}

stop() {
  systemctl stop NetworkManager
}

toggle() {
  status
  if [ $? = 0 ]; then
    stop
  else
    start
  fi
}

info() {
  status
  if [ $? = 0 ]; then
    eww update net_service_info=true
  else
    eww update net_service_info=false
  fi
}

if [ "$1" = "start" ]; then
  start
elif [ "$1" = "stop" ]; then
  stop
elif [ "$1" = "toggle" ]; then
  toggle
else
  info
fi